public class StaticDispatch {
    static abstract class Human {

    }

    static class Man extends Human {}

    static class Woman extends Human {}

    // 虚拟机在重载时是通过参数的静态类型而不是实际类型作为判断依据的
    public void sayHello(Human guy) {
        System.out.println("hello, guy!");
    }

    public void sayHello(Man guy) {
        System.out.println("hello, gentlemen!");
    }

    public void sayHello(Woman guy) {
        System.out.println("hello, lady!");
    }

    public static void main(String[] args) {
        // Human: 变量的“静态类型”
        // Man: 变量的“实际类型”
        Human man = new Man();
        Human woman = new Woman();
        StaticDispatch sr = new StaticDispatch();
        sr.sayHello(man);
        sr.sayHello(woman);
    }
}
